home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / src / appui.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  4.0 KB  |  152 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_CORE2_SEG
  14. #pragma code_seg(AFX_CORE2_SEG)
  15. #endif
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CWinApp User Interface Extensions
  24.  
  25. void CWinApp::OnAppExit()
  26. {
  27.     // same as double-clicking on main window close box
  28.     ASSERT(m_pMainWnd != NULL);
  29.     m_pMainWnd->SendMessage(WM_CLOSE);
  30. }
  31.  
  32. #ifdef AFX_CORE3_SEG
  33. #pragma code_seg(AFX_CORE3_SEG)
  34. #endif
  35.  
  36. void CWinApp::HideApplication()
  37. {
  38.     ASSERT_VALID(m_pMainWnd);
  39.  
  40.     // hide the application's windows before closing all the documents
  41.     m_pMainWnd->ShowWindow(SW_HIDE);
  42. #if !defined(_WIN32_WCE)
  43.     m_pMainWnd->ShowOwnedPopups(FALSE);
  44. #endif // _WIN32_WCE
  45.  
  46.     // put the window at the bottom of zorder, so it isn't activated
  47.     m_pMainWnd->SetWindowPos(&CWnd::wndBottom, 0, 0, 0, 0,
  48.         SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
  49. }
  50.  
  51. void CWinApp::DoWaitCursor(int nCode)
  52. {
  53.     // 0 => restore, 1=> begin, -1=> end
  54. #if !defined(_WIN32_WCE)
  55. // WinCE: except.cpp passes in a different value, so don't ASSERT
  56.     ASSERT(nCode == 0 || nCode == 1 || nCode == -1);
  57. #endif // _WIN32_WCE
  58.     ASSERT(afxData.hcurWait != NULL);
  59.     AfxLockGlobals(CRIT_WAITCURSOR);
  60.     m_nWaitCursorCount += nCode;
  61.     if (m_nWaitCursorCount > 0)
  62.     {
  63.         HCURSOR hcurPrev = ::SetCursor(afxData.hcurWait);
  64.         if (nCode > 0 && m_nWaitCursorCount == 1)
  65.             m_hcurWaitCursorRestore = hcurPrev;
  66.     }
  67.     else
  68.     {
  69.         // turn everything off
  70.         m_nWaitCursorCount = 0;     // prevent underflow
  71.         ::SetCursor(m_hcurWaitCursorRestore);
  72.     }
  73.     AfxUnlockGlobals(CRIT_WAITCURSOR);
  74. }
  75.  
  76.  
  77. BOOL CWinApp::SaveAllModified()
  78. {
  79.     if (m_pDocManager != NULL)
  80.         return m_pDocManager->SaveAllModified();
  81.     return TRUE;
  82. }
  83.  
  84. void CWinApp::AddToRecentFileList(LPCTSTR lpszPathName)
  85. {
  86.     ASSERT_VALID(this);
  87.     ASSERT(lpszPathName != NULL);
  88.     ASSERT(AfxIsValidString(lpszPathName));
  89.  
  90.     if (m_pRecentFileList != NULL)
  91.         m_pRecentFileList->Add(lpszPathName);
  92. }
  93.  
  94. CDocument* CWinApp::OpenDocumentFile(LPCTSTR lpszFileName)
  95. {
  96.     ASSERT(m_pDocManager != NULL);
  97.     return m_pDocManager->OpenDocumentFile(lpszFileName);
  98. }
  99.  
  100. void CWinApp::CloseAllDocuments(BOOL bEndSession)
  101. {
  102.     if (m_pDocManager != NULL)
  103.         m_pDocManager->CloseAllDocuments(bEndSession);
  104. }
  105.  
  106. /////////////////////////////////////////////////////////////////////////////
  107. // MRU file list default implementation
  108.  
  109. void CWinApp::OnUpdateRecentFileMenu(CCmdUI* pCmdUI)
  110. {
  111.     ASSERT_VALID(this);
  112.     if (m_pRecentFileList == NULL) // no MRU files
  113.         pCmdUI->Enable(FALSE);
  114.     else
  115.         m_pRecentFileList->UpdateMenu(pCmdUI);
  116. }
  117.  
  118. /////////////////////////////////////////////////////////////////////////////
  119. // DDE and ShellExecute support
  120.  
  121. BOOL CWinApp::OnDDECommand(LPTSTR lpszCommand)
  122. {
  123.     if (m_pDocManager != NULL)
  124.         return m_pDocManager->OnDDECommand(lpszCommand);
  125.     else
  126.         return FALSE;
  127. }
  128.  
  129. /////////////////////////////////////////////////////////////////////////////
  130. // MRU file list default implementation
  131.  
  132. BOOL CWinApp::OnOpenRecentFile(UINT nID)
  133. {
  134.     ASSERT_VALID(this);
  135.     ASSERT(m_pRecentFileList != NULL);
  136.  
  137.     ASSERT(nID >= ID_FILE_MRU_FILE1);
  138.     ASSERT(nID < ID_FILE_MRU_FILE1 + (UINT)m_pRecentFileList->GetSize());
  139.     int nIndex = nID - ID_FILE_MRU_FILE1;
  140.     ASSERT((*m_pRecentFileList)[nIndex].GetLength() != 0);
  141.  
  142.     TRACE2("MRU: open file (%d) '%s'.\n", (nIndex) + 1,
  143.             (LPCTSTR)(*m_pRecentFileList)[nIndex]);
  144.  
  145.     if (OpenDocumentFile((*m_pRecentFileList)[nIndex]) == NULL)
  146.         m_pRecentFileList->Remove(nIndex);
  147.  
  148.     return TRUE;
  149. }
  150.  
  151. /////////////////////////////////////////////////////////////////////////////
  152.